export default function rng(): Promise<Uint8Array> {
  return new Promise(resolve => {
    uni.getRandomValues({
      length: 16,
      success: res => {
        resolve(new Uint8Array(res.randomValues))
      },
      fail: () => {
        // throw new Error("Failed to get random values");
        resolve(
          new Uint8Array(
            (Date.now().toString() + Date.now().toString())
              .slice(-16)
              .split('')
              .map(v => parseInt(v)),
          ),
        )
      },
    })
  })
}
